All Questions
8 questions
0votes
1answer
110views
uncomment the line upon search string while ignoring case in a file
Below is my cron file entries: #Ansible: test2 */15 * * * * ansible-playbook /web/playbooks/automation/detect401MORTEN/va_action.yml | tee -a /web/playbooks/automation/detect401MORTEN/cron.out # #...
0votes
2answers
1kviews
Replace specified strings in file with strings from other file with sed [duplicate]
I have two files like this. file1 line 1 line 2 ... (more lines) aaa PLACEHOLDER bbb ccc ... (more lines) ddd PLACEHOLDER eee fff ... (more lines) etc file2 NEWTEXT1 NEWTEXT2 ... (more lines) There ...
0votes
2answers
493views
How to do find and replace strings on file after it is being modified
Trying to achieve following: 1) New file gets uploaded with the same file name but with new content 2) Event triggers that checks the file for specific strings and replaces them 3) The file can be ...
2votes
1answer
2kviews
How to express beginning and end of line in sed
I want to use sed to replace every '} that comes at the end of the line to "}. I wrote: sed -i -e "s/'}$/\"}$/g" But this replaces it to: "}$. What is wrong? How can I use regex in my sed to express ...
2votes
3answers
585views
Conditionally replace lines of file1 with the corresponding lines of file2
For example, I have two files: file1: 1 4 X 5 X 7 file2: 2 3 5 X X 1 I want to replace X-lines of file1 with whatever is in file2 on the corresponding line: result: 1 4 5 5 X 7 I prefer the ...
2votes
2answers
626views
Using sed (or anything useful) to replace strings with relative content
Usually to replace strings across multiple files, one simply needs to use sed -i 's/string1/string2/g' * However, how could I use the sed command (or anything that works, really) to replace things ...
11votes
3answers
42kviews
Save file after using sed command
I am using following command to replace yyyymmdd to YYYYMMDDHH24MISS in my file: sed -e 's/\('yyyymmdd'\)/\('YYYYMMDDHH24MISS'\)/g' filename After I run the command in PuTTY, it displays the file ...
3votes
5answers
1kviews
Replacing lines in files with file contents
I have several files which contain some PHP includes and I want to substitute them with the file contents. The file looks like foo <?php include("file1.php"); ?> bar baz <?php include("file2....